$("#top1 .menu").click(function() {
    $("#dropdown-menus").show();

    if (context.user && context.user.user && context.user.user.mobile) {
        $("#dropdown-menus .charge").show();
        $("#dropdown-menus .withdraw").show();
    }
    else {
        $("#dropdown-menus .charge").hide();
        $("#dropdown-menus .withdraw").hide();
    }

    $("#dropdown-menus .weijie").html("--");
    Lottery.refresh_uncheck(function() {
        $("#dropdown-menus .weijie").html("(" + (query_uncheck_bets_total()/100).toFixed(2) + ")");
    })

    $("#dropdown-menus .win").html("--");
    Result.todayProfit(function(r) {
        $("#dropdown-menus .win").html("(" + (r.amount/100).toFixed(2) + ")");
    }, function() {
        $("#dropdown-menus .win").html("(0)");
    });
})
$("#dropdown-menus .bg").click(function() {
    $("#dropdown-menus").hide();
});

function jumpToCenter(cmd, n) {
    Util.jumpUrl({
        file: 'center.html',
        back: "game",
        cmd: cmd,
        n: n || '',
    });
}
$("#dropdown-menus .jszd").click(function() {
    jumpToCenter("jishi");
});
$("#dropdown-menus .jryj").click(function() {
    jumpToCenter("today");
});
$("#dropdown-menus a.today").click(function() {
    jumpToCenter("today");
});
$("#dropdown-menus .bet").click(function() {
    if (context.user && context.user.user && context.user.user.mobile)
        jumpToCenter("bet");
    else {
        $("#dropdown-menus").hide();
        alert2("试玩账号无权访问，请先注册");
    }
});
$("#dropdown-menus .long").click(function() {
    jumpToCenter("long");
});
$("#dropdown-menus .result").click(function() {
    jumpToCenter("result");
});
$("#dropdown-menus .luzhu").click(function() {
    jumpToCenter("luzhu");
});
$("#dropdown-menus .charge").click(function() {
    jumpToCenter("charge");
});
$("#dropdown-menus .withdraw").click(function() {
    jumpToCenter("charge", "take");
});

//  游戏规则
$("#dropdown-menus .rule").click(function() {
    $("#game_rule .rule-title").html(get_game_display_name(game));
    startSpin();
    $.get("../public/all/pages/rule/rule_" + game + ".html", function(r) {
        stopSpin();
        $("#game_rule .scroll .for-scroll").empty();
        $("#game_rule .scroll .for-scroll").html(r);

        $("#game_rule").modal({
            width: $(document).width() - 70,
            height: $(document).height() - 70,
        });
        $("#game_rule .rule-content .am-titlebar").hide();
        _ruleScroll.refresh();
        setTimeout(function() {
            _ruleScroll.refresh();
        }, 500);
    });
    $("#dropdown-menus").hide();
});
var _ruleScroll;
$(function() {
    _ruleScroll = new IScroll("#game_rule_content .scroll", {
        scrollX: false,
        scrollY: true,
        click: true,
    })
});

// 左边菜单动画
var __hideAni = function() {
    var i = parseInt($("#system-menus .list").css("left"));
    if (i <= -180) {
        $("#system-menus").hide();
        $("#page-main").css("left", "0px");
        $("#page-main").css("right", "0px");
        return;
    }
    i -= 25;
    if (i < -180) i = -180;
    $("#system-menus .list").css("left", i + "px");
    $("#page-main").css("left", (180 + i) + "px");
    $("#page-main").css("right", -(i + 180) + "px");
    setTimeout(function() {
        __hideAni();
    }, 40);
};
$("#system-menus .bg").click(function() {
    __hideAni();
})
$("#top1 .game").click(function() {
    var showAni = function() {
        var i = parseInt($("#system-menus .list").css("left"));
        if (i >= 0) {
            $("#system-menus .list").css("left", "0px");
            $("#page-main").css("left", "180px");
            $("#page-main").css("right", "-180px");
            return;
        }
        i += 25;
        if (i > 0) i = 0;
        $("#system-menus .list").css("left", i + "px");
        $("#page-main").css("left", (180 + i) + "px");
        $("#page-main").css("right", -(i + 180) + "px");
        setTimeout(function() {
            showAni();
        }, 40);
    }
    $("#system-menus").show();
    _gameMenuScroll.refresh();
    $("#system-menus .list").css("left", "-180px");
    $("#page-main").css("left", "0px");
    $("#page-main").css("right", "0px");
    showAni();
});